## MineTest.Me

This a mod that should provide tools I have created that I find useful in my
own Mintest servers. Currenly I'm focusing on storage options for different
mods that normally use flat files.

## Objective

The objective is to be able to have simple easy access to the data with minimal
coding and effort. At the moment that means allowing any module to create a
key/value table in SQLite3 or Postgres. Each table would be represented by
a lua table, and as much as possible emulate a lua table.

## Target

This mod might be useful to others, but it's mainly targeted at larger servers
since it might allow for servers without any local storage, using postgresql.
This should enable an easier implementation of an automated container
deployment. It should also be more stable, since past methods have been to
serialize information all players and write the entire set of data to a file.
If anything should go wrong during serialization all the data for that mod
would be lost. We should be able to cut down on I/O and better safeguard data
while increasing performance.

## Dependence

[Luarocks](https://luarocks.org/)
[LuaSQL](https://keplerproject.github.io/luasql/) luasql-sqlite3 &
luasql-postgres

## Features

Detects backend storage types, ether sqlite3 or postgres at the moment,
defaulting to sqlite3.

If the table name does not exist it will be created automatically.

If serialize and deserialize functions are passed as options values will
be processed automatically. This allows for tables to be passed as values. If
the minetest mod execution environment is detected then this is automatic.

Just as with serialization compression can be automatic by passing two function
with the options compress and decompress. This will enable automatic
compression of values. This is automatic when running with minetest.

## Code Example

If these mod were used to save bed spawns.

```
spawns = mtm.storage()

spawns['dave'] = {x = 1, y = 10, z = 100}
minetest.log("info", "MTM dave.z " .. spawns.dave.z)
```

Appending values to the same table by using the storage object is done by
using the object as a function.

```
spawns("a") -- Same as spawn[1] = "a"
spawns("b") -- Same as spawn[2] = "b"
spawns("c") -- Same as spawn[3] = "c"
```

## Installation

On Ubuntu

```
# apt install luarocks unzip
```

Sqlite3 backend

```
# apt install sqlite3
# luarocks install luasql-sqlite3
```

PostgreSQL backend

```
# apt install postgresql-client
# luarocks install luasql-postgres
```

Download mod to your mods directory.

```
wget http://gitlab.catch22.com/james/mtm/repository/archive.zip
unzip archive.zip

```

## API Reference

[Lua Tables](https://www.lua.org/pil/2.5.html)
[Metatables/Metamethods](http://lua-users.org/wiki/MetamethodsTutorial)
[Luarocks](https://luarocks.org/)
[Postgresql Connection Strings](https://www.postgresql.org/docs/10/static/libpq-connect.html#LIBPQ-CONNSTRING)

## Tests



## How to use?



## Contribute

Let people know how they can contribute into your project. A [contributing guideline](https://github.com/zulip/zulip-electron/blob/master/CONTRIBUTING.md) will be a big plus.

## Credits
Give proper credits. This could be a link to any repo which inspired you to build this project, any blogposts or links to people who contrbuted in this project.

#### Anything else that seems useful

## License
A short snippet describing the license (MIT, Apache etc)

MIT © [James Dornan](james_AT_catch22.com)
